package com.liuyucheng.designpattern.原型模式;

import java.util.Date;

public class BiliBili {
    public static void main(String[] args) throws CloneNotSupportedException {
        //原型对象
        Video v1 = new Video("原始视频", new Date());
        Item item = new Item();
        item.setName("1111");
        v1.setItem(item);

        System.out.println(v1);
        System.out.println(v1.getItem());
        System.out.println(v1.hashCode());

        System.out.println("==================");

        //克隆出v2(这种属于浅拷贝,属性如果是对象,只会拷贝引用,如果要实现深拷贝,重写clone方法,将这个对象的属性也进行clone)
        Video v2 = (Video) v1.clone();
        System.out.println(v2);
        System.out.println(v2.getItem());
        System.out.println(v2.hashCode());
    }
}
